package com.geekhalo.admin.domain.user;

import com.geekhalo.admin.domain.user.UserView;
import com.geekhalo.admin.domain.user.query.GetByLoginName;
import com.geekhalo.lego.core.query.AbstractView;
import lombok.AccessLevel;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

import javax.persistence.*;

@Entity
@Table(name = "user")
@Data
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Setter(AccessLevel.PRIVATE)
public class UserView extends AbstractView { 
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;


    private UserStatus status;

    private String loginName;

    private String loginPassword;

    private String showName;

    public boolean checkPassword(String password){
        return StringUtils.isNoneEmpty(this.loginPassword)
                && this.loginPassword.equals(password);
    }
}